// index.js
Component({
    options: {
        addGlobalClass: true,
    },
    /**
     * 组件的属性列表
     */
    properties: {
        show: {
            type: Boolean,
            value: false
        },
        exStyle: {
            type: Object,
            value: {}
        }
    },
    lifetimes: {
        ready() {

        }
    },
    /**
     * 组件的初始数据
     */
    data: {

    },
    observers: {
        'show': function (newVal) {
            if ( newVal ) {
                this.closeToast();
            }
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        closeToast() {
            const that = this;
            let timer = 0;
            timer = setTimeout(() => {
                clearTimeout(timer);
                that.$store.setState({
                    'toast.show': false
                })
                if(typeof that.toastSuccess == 'function') {
                    this.toastSuccess( { type: 'timeEnd'});
                }
            }, that.$store.getState().toast.duration);
        }
    }
})